package com.campus.mapper;

import com.campus.domain.entity.CommentLike;
import org.apache.ibatis.annotations.*;

/**
 * 评论点赞Mapper
 */
@Mapper
public interface CommentLikeMapper {
    
    // 插入点赞
    @Insert("INSERT INTO comment_likes(comment_id, user_id) VALUES(#{commentId}, #{userId})")
    int insert(CommentLike like);
    
    // 删除点赞
    @Delete("DELETE FROM comment_likes WHERE comment_id = #{commentId} AND user_id = #{userId}")
    int delete(@Param("commentId") Long commentId, @Param("userId") Long userId);
    
    // 查询是否已点赞
    @Select("SELECT COUNT(*) FROM comment_likes WHERE comment_id = #{commentId} AND user_id = #{userId}")
    int exists(@Param("commentId") Long commentId, @Param("userId") Long userId);
}

